﻿@using System.Globalization
@using BookShop.Library.Common
@using HTN.Library
@model BookShop.Site.Models.HomeViewModel
<!-- BEGIN SIDEBAR -->
<div id="category-sidebar" class="sidebar col-md-3 col-sm-5">
    <ul class="list-group margin-bottom-25 sidebar-menu">
        @if (Model != null)
        {
            if (Model.CategoryList != null)
            {
                foreach (var item in Model.CategoryList)
                {
            <li class="list-group-item clearfix">
                <a href="@Url.Action("ProductPage", "Home", new { categoryId = item.Id })"><i class="fa fa-angle-right"></i>@item.Name</a>
            </li>
                }
            }
        }
    </ul>
    @if (Model != null && Model.HasPriceSlider)
    {
        <div class="sidebar-filter margin-bottom-25">
            <h3>Giá</h3>
            <p>
                <label for="amount">Khoảng:</label>
                <input type="text" id="amount" style="border: 0; color: #f6931f; font-weight: bold;">
            </p>
            <div id="slider-range"></div>
            <form action="@Url.Action("ProductPage", "Home", new
                          {
                              title = ViewBag.SearchTitle,
                              authorId = ViewBag.SearchAuthorId,
                              sort = ViewBag.SearchSort,
                              categoryId = ViewBag.SearchCategoryId,
                              publisherId = ViewBag.SearchPublisherId
                          })">
                <input type="hidden" value="" id="fromPrice" name="fromPrice" />
                <input type="hidden" value="" id="toPrice" name="toPrice" />
                <input type="submit" class="btn btn-default" style="margin-top: 20px;" value="Lọc" />
            </form>
        </div>
    }
    @if (Model != null)
    {
        if (Model.BestSellerBookList != null)
        {
        <div class="sidebar-products clearfix">
            <h2><a href="@Url.Action("BestsellerPage", "Home")">Bestsellers</a></h2>
            @{
            var bookList = Model.BestSellerBookList.Take(3).ToList();
            foreach (var book in bookList)
            {
                <div class="item">
                    <a href="@Url.Action("Detail", "Book", new { bookId = book.Id })">
                        <img src="@Utility.UrlCombine(CommonFunction.GetConfigValue("SiteUrl"), book.PictureUrl)" alt="@book.Title"></a>
                    <h3><a href="@Url.Action("Detail", "Book", new { bookId = book.Id })">@book.Title</a></h3>
                    <div class="price my-price">
                        @if (book.IsOnSale)
                        {
                            @book.DiscountPrice.ToString(CultureInfo.CreateSpecificCulture("en-US"))@("Đ")
                            <em><span>@book.Price.ToString(CultureInfo.CreateSpecificCulture("en-US"))</span>(Đ)</em>
                        }
                        else
                        {
                            @book.Price.ToString(CultureInfo.CreateSpecificCulture("en-US"))@("Đ")
                        }
                    </div>
                </div>
            }
            }
        </div>
        }
    }
</div>
<!-- END SIDEBAR -->
